﻿function MarblesApplication() {
    this.GetXmlHttp = function() {
        var oXmlHttp = false;

        if (XMLHttpRequest) { oXmlHttp = new XMLHttpRequest(); }
        else {
            try {
                oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                    oXmlHttp = false;
                }
            }
        }

        return oXmlHttp;
    }

    this.GetResponseText = function(url) {
        var oXmlHttp = this.GetXmlHttp();
        oXmlHttp.open('GET', url, false);
        oXmlHttp.setRequestHeader('Pragma', 'no-cache');
        oXmlHttp.send(null);
        return oXmlHttp.responseText;
    }

    this.GetResponseXML = function(url) {
        var oXmlHttp = this.GetXmlHttp();
        oXmlHttp.open('GET', url, false);
        oXmlHttp.setRequestHeader('Pragma', 'no-cache');
        oXmlHttp.send(null);
        return oXmlHttp.responseXML;
    }

    this.OpenWindow = function(url, width, height, ismodal) {
        if (document.all) {
            var xwid = screen.width;
            var yhei = screen.height;
        } else {
            if (document.layers) {
                var xwid = window.outerWidth;
                var yhei = window.outerHeight;
            } else {
                var xwid = 800;
                var yhei = 600;
            }
        }
        var xoffset = (xwid - width) / 2;
        var yoffset = (yhei - height) / 2;
        var state = '';

        if (ismodal == false) {
            x = window.open(url, '', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=' + width + ',height=' + height + ',screenX=' + xoffset + ',screenY=' + yoffset + ',top=' + yoffset + ',left=' + xoffset);
            x.focus();
        } else {
            state = window.showModalDialog(url, '', 'scroll:no;scroll:0;dialogHeight: ' + height + 'px; dialogWidth: ' + width + 'px; edge: Raised; center: Yes; help: No; resizable: Yes; status: Yes;screenX:' + xoffset + ';screenY:' + yoffset + ';top:' + yoffset + ';left:' + xoffset);
        }

        return state;
    }
}
